<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

class ResetRoles extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'reset:roles';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        DB::table('roles')->truncate();
        $data = [
            ['name' => 'admin', 'name_cn' => '超级管理员'],
            ['name' => 'manage', 'name_cn' => '普通管理员'],
            ['name' => 'hr', 'name_cn' => '人事'],
            ['name' => 'user', 'name_cn' => '普通预览者'],
        ];
        DB::table('roles')->insert($data);
        $this->info('roles table reset successfully!');
    }
}
